function loadExchange() {
  $('.append').remove()
  $('#mainContent').append(template('t_exchange'))
  exit()
  var sellType = 0
  var page = 0
  $('.link').click(function() {
    $next = $(this).next('.submenu')
    $next.slideToggle()
    $(this).parent().toggleClass('open')
    $('#accordion').find('.submenu').not($next).slideUp().parent().removeClass('open')
  })

  $('.submenu li').click(function() {
    $(this).toggleClass('active')
    $('#accordion').find('li').not($(this)).removeClass('active')
    var value = $(this).attr('value')
    sellType = value
    page = 0
    getTrades()
  })

  getTrades()

  function getTrades() {
    request.getTradeInfo(sellType, page, function(res) {
      var trades = res.trades
      var html = ''
      for (var i = 0; i < trades.length && i < 8; i++) {
        var id = trades[i]._id
        var itemName = propName[trades[i].itemId] + 'X' + trades[i].itemNum
        var pName = trades[i].pName
        var sellGold = trades[i].sellGold
        html += '<div class="line">'
        html += '<div class="title1">' + itemName + '</div><div class="title2">' + pName + '</div>'
        html += '<div class="title3">' + sellGold + '</div><div class="title4 buy' + id + '"><button class="buy" value="' + id + '">购买</button></div>'
        html += '</div>'
      }
      $('.content').html(html)
      $('.buy').click(function() {
        var value = $(this).attr('value')
        request.bugTrade(value, function(res) {
          if (res.error === 2) {
            $('.buy' + value).html('已出售')
            showMessage('物品不存在')
          } else if (res.error === 3) {
            showMessage('无法购买自己出售的东西')
          } else if (res.error === 4) {
            showMessage('金币不足')
          } else if (res.error === 0) {
            showMessage('购买成功,物品已发送到你的邮箱,请查看')
            $('.buy' + value).html('已购买')
          }
        })
      })

      if (res.isFirst) {
        $('.prev').css('display', 'none')
      } else {
        $('.prev').css('display', 'inline-block')
      }

      if (res.isLast) {
        $('.next').css('display', 'none')
      } else {
        $('.next').css('display', 'inline-block')
      }
    })
  }

  $('.prev').click(function() {
    if (page <= 0) {
      return
    }
    page -= 1
    getTrades()
  })

  $('.next').click(function() {
    page += 1
    getTrades()
  })

  $('.return').click(function(){
    loadExchange()
  })

  $('.mySell').click(function() {
    request.getMyTradeInfo(function(res) {
      if (res.error !== 0) {
        showMessage('你没有上架的物品')
        return
      }
      if(res.trades.length <= 0){
        showMessage('你没有上架的物品')
        return
      }
      $('.mySell').css('display','none')
      $('.return').css('display','inline-block')
      var trades = res.trades
      var html = ''
      for (var i = 0; i < trades.length && i < 8; i++) {
        var id = trades[i]._id
        var itemName = propName[trades[i].itemId] + 'X' + trades[i].itemNum
        var pName = trades[i].pName
        var sellGold = trades[i].sellGold
        html += '<div class="line">'
        html += '<div class="title1">' + itemName + '</div><div class="title2">' + pName + '</div>'
        html += '<div class="title3">' + sellGold + '</div><div class="title4 cancelSell' + id + '"><button class="cancelSell" value="' + id + '">下架</button></div>'
        html += '</div>'
      }
      $('.content').html(html)
      $('.prev').css('display', 'none')
      $('.next').css('display', 'none')

      $('.cancelSell').click(function() {
        var value = $(this).attr('value')
        request.cancelSell(value, function(res) {
          if (res.error === 0) {
            showMessage('你下架了你的物品,请到邮箱查收')
            $('.cancelSell' + value).html('已下架')
          } else if (res.error === 2) {
            showMessage('物品已不存在')
            $('.cancelSell' + value).html('不存在')
          }
        })
      })
    })
  })
}
